Select default emulator on first run#217
Conversation
e1db26a to
4204284
Compare
|
@anisaoshafi @gtsiolis it feels a bit odd to me that the Users can still manually edit their config if they want to. If we want to provide a way to reset the emulator in the config from command line, what about something like
|
Good point, can be too much of a responsibility for a flag. I like |
If we decide for another command, I think we can leave it out of the scope of this PR/create another issue for it to keep this PR small. |
| tag = "latest" | ||
| port = "4566" | ||
| # volume = "" # Host directory for persistent state (default: OS cache dir) | ||
| # env = [] # Named environment profiles to apply (see [env.*] sections below)` |
There was a problem hiding this comment.
question:
At the moment those blocks are duplicated and there is a chance of drift.
How hard it is to parse those blocks from default_config.toml?
Another solution could be to use go templates in default_config.toml so the container blocks could come from another file.
|
Looking at this now! 👀 |
ada0134 to
5e7723a
Compare
| type = "snowflake" | ||
| tag = "latest" | ||
| port = "4566" |
There was a problem hiding this comment.
issue: Similar to what @carole-lavillonniere mentioned above, this leads to content duplication.
# [[containers]]
# type = "aws" # Emulator type. Currently supported: "aws", "snowflake"
# tag = "latest" # Docker image tag, e.g. "latest", "2026.03"
# port = "4566" # Host port the emulator will be accessible on
# # volume = "" # Host directory for persistent state (default: OS cache dir)
# # env = [] # Named environment profiles to apply (see [env.*] sections below)
[...]
[[containers]]
type = "snowflake"
tag = "latest"
port = "4566"
# volume = "" # Host directory for persistent state (default: OS cache dir)
# env = [] # Named environment profiles to apply (see [env.*] sections below)I'd expect if I select SNO on start, to simply use snowflake in the first [[containers]] section.
[...]
[[containers]]
type = "snowflake" # Emulator type. Currently supported: "aws", "snowflake"
tag = "latest" # Docker image tag, e.g. "latest", "2026.03"
port = "4566" # Host port the emulator will be accessible on
volume = "" # Host directory for persistent state (default: OS cache dir)
env = [] # Named environment profiles to apply (see [env.*] sections below)
[...]There was a problem hiding this comment.
I'm going to tackle this 💯
| Prompt: "Which emulator would you like to use?", | ||
| Options: []output.InputOption{ | ||
| {Key: "a", Label: "AWS [A]"}, | ||
| {Key: "s", Label: "Snowflake [S]"}, |
There was a problem hiding this comment.
There was a problem hiding this comment.
yes, comes from emulator side. I created a follow up task: DRG-818 for handling this error in a nicer way since it's out of the scope for this PR 🙏🏼
|
|
||
| msg := selected.DisplayName() + " emulator selected." | ||
| if configPath != "" { | ||
| msg += fmt.Sprintf(" You can change this anytime in %s.", configPath) |
There was a problem hiding this comment.
@gtsiolis Does this look a bit better? Also changed the message as you proposed in the other comment 
There was a problem hiding this comment.
same success message as the AWS profile creation
What does this mean when the user selects snowflake on first try?
@gtsiolis sorry, I'm not following. Can you rephrase your suggestion?
Did you mean Change configuration in ~/.config/lstk/config.toml should have a green tick in front?
| labelCh <- label | ||
| } | ||
|
|
||
| func selectEmulatorInTUI( |
There was a problem hiding this comment.
praise: Thanks for reusing this UX!
|
|
||
| return newCfg.Containers, nil | ||
| } | ||
|
|
There was a problem hiding this comment.
issue: now I think we should just move selectEmulatorInTUI and resolveAndCacheLabel out of internal/ui and we should be good. These are domain code.
AGENTS.md is kind of documenting this with:
- Do not pass UI callbacks like
onProgress func(...)through domain layers; prefer typed output events.
- Keep UI as presentation/orchestration only; business logic stays in domain packages.
domain packages => everything under internal/ except internal/ui/.
A test for "is this domain code?": if we wired a different kind of frontend, domain code should still work.
AGENTS.md does not explicitly say where the code executed upon user input lives, though. I think it'd be good to add a line about this.
| return name | ||
| } | ||
| return string(e) | ||
| } |
There was a problem hiding this comment.
question: we already have DisplayNameForType line 77.
Can we
- refactor to make them one?
- or rename to make more explicit?
- and/or change the signatures so that they are both methods?
| Prompt: "Which emulator would you like to use?", | ||
| Options: []output.InputOption{ | ||
| {Key: "a", Label: "AWS"}, | ||
| {Key: "s", Label: "Snowflake"}, |
There was a problem hiding this comment.
nit: possible to build the options from emulatorDisplayNames or another map, to make it more dynamic?
| } | ||
| *firstRun, err = config.Init() | ||
| return err | ||
| } |
There was a problem hiding this comment.
question: do we really need 2 functions initConfig and initConfigCapturingFirstRun? They look quite similar
|
|
||
| cancel() | ||
| <-outputCh | ||
| } |
There was a problem hiding this comment.
suggestion: what about completing this test with an actual user input, making sure we persist the choice in the config and start that chosen emulator?
There was a problem hiding this comment.
suggestion: we could also add a simple test to make sure we don't prompt when the config is already created?
…ation message is secondary
f4d7f78 to
3d88700
Compare


First-time users are prompted to choose their emulator (AWS or Snowflake) before lstk starts (to simulate this, rename or delete config.toml). The choice is saved to the config file immediately.
--non-interactive/ no TTY it silently uses the AWS by default.